<!--付费判断-->
{php $shipinbiao = \Phpcmf\Service::M()->db->table('1_quan_shipin_buy')->where('cid', $t.id)->where('uid', $member.uid)->get()->getRowArray();}
<!--积分判断-->

{if $t.shipinyuedumoshi == '1'}
	<!--免费阅读-->
	<div class="d-kuan d-shang-15 d-xia-10">
		{loop $t.shipin $i $c}
		<div class="d-kuan">
			<div class="">
				<div id="dplayer-{$i}-{$t.id}" class="d-shang-10 d-yuanjiao-10 "></div>
			</div>
			<div class="d-clear"></div>
		</div>
		{/loop}
	</div>
{elseif $t.shipinyuedumoshi == '2'}
<!--付费阅读-->
	{if $shipinbiao || $t.uid == $member.id || $member.is_admin}
		{loop $t.shipin $i $c}
		<div class="d-kuan">
			<div class="">
				<div id="dplayer-{$i}-{$t.id}" class="d-shang-10 d-yuanjiao-10 "></div>
			</div>
			<div class="d-clear"></div>
		</div>
		{/loop}
	{else}
		<div class="d-kuan d-shang-10 d-gao-378 d-wenzi-juzhong d-xia-15 d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
			<img src="{HOME_THEME_PATH}web/img/shipin1.png" width="60" height="60" style="margin-top: 70px;"/>
			<br>付费观看视频
			<br><span class="d-zitiyanse-hongse">{$t.shipinyuedujinbi}  元</span>
			<br>
			<a href="{dr_url('quan/buyshipin/index', ['fid' => 0,'id'=> $t.id])}">
			<div class="d-kuan-juzhong d-kuan-50 d-hanggao-30 d-wenzi-juzhong d-shang-5 d-wenzi-12 d-beijing-hei d-yuanjiao-20 d-zitiyanse-bai">
				购 买
			</div>
			</a>
		</div>
	{/if}
{elseif $t.shipinyuedumoshi == '3'}
	<!--积分阅读-->
	{if $shipinbiao || $t.uid == $member.id || $member.is_admin}
			{loop $t.shipin $i $c}
			<div class="d-kuan">
				<div class="">
					<div id="dplayer-{$i}-{$t.id}" class="d-shang-10 d-yuanjiao-10 "></div>
				</div>
				<div class="d-clear"></div>
			</div>
			{/loop}
		{else}
			<div class="d-kuan d-shang-10 d-gao-378 d-wenzi-juzhong d-xia-15 d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
				<img src="{HOME_THEME_PATH}web/img/shipin1.png" width="60" height="60" style="margin-top: 70px;"/>
				<br>积分观看视频
				<br><span class="d-zitiyanse-hongse">{$t.shipinyuedujifen}  {SITE_SCORE}</span>
				<br>
				<a href="{dr_url('quan/buyshipinjifen/index', ['fid' => 0,'id'=> $t.id])}">
				<div class="d-kuan-juzhong d-kuan-50 d-hanggao-30 d-wenzi-juzhong d-shang-5 d-wenzi-12 d-beijing-hei d-yuanjiao-20 d-zitiyanse-bai">
					购 买
				</div>
				</a>
			</div>
		{/if}
{/if}
<style>
	.dplayer-controller .dplayer-icons .dplayer-setting {
		display: none;
	}
	.dplayer-controller .dplayer-icons .dplayer-time, .dplayer-controller .dplayer-icons .dplayer-live-badge {
		display: none;
	}
	.dplayer.dplayer-mobile .dplayer-controller .dplayer-icons .dplayer-full .dplayer-full-in-icon {
		display: none;
	}
	.dplayer-controller .dplayer-icons.dplayer-icons-left .dplayer-icon {
		display: none;
	}
</style>

<script>
	{if $shipinbiao || $t.uid == $member.id || $member.is_admin || $t.shipinyuedumoshi == '1'}
	{loop $t.shipin $i $c}
	<?php
		$info = \Phpcmf\Service::C()->get_attachment($c.file);
		if (is_file($info['file'])) {
			$sell = 'ffmpeg -i '.$info['file'].' -r 30 -t 4 '.$info['file'].'.jpg';
			shell_exec($sell);
			// 这样就生成了一个.jpg的后缀缩略图
			//echo $info['url'].'.jpg';
		} else {
			// 文件不存在于本地磁盘
		}
	?>
	const dp{$i}{$t.id} = new DPlayer({
			container: document.getElementById('dplayer-{$i}-{$t.id}'),
			video: {
				url: '{dr_get_file($c.file)}',
				pic: '{$info['url'].'.jpg'}',
			},
		});
	var selectObj = $("#dplayer-{$i}-{$t.id}").children();
		//console.log(selectObj[1].childNodes[1]);  
	//var video{$i} = $('.dplayer-video').parent().parent('#dplayer-{$i}'); //当前视频对象;
	var video{$i}{$t.id} = selectObj[1].childNodes[1];//当前视频对象;
	//console.log(video{$i}{$t.id});  
	//$('#item1').parent('.parent1') document.querySelector(“p.lover”);
	//var video{$i} = document.getElementsByTagName(".dplayer-video");
	video{$i}{$t.id}.onloadedmetadata=function(res){
		//console.log('媒介元素的持续时间以及其他媒介数据已加载时运行脚本：',res);  
		//窗体
		var window_Width=window.innerWidth;
		var window_Height=window.innerHeight;  
		//console.log('窗体-宽度：',window_Width);
		//console.log('窗体-高度：',window_Height);
		//原视频
		var videoWidth=video{$i}{$t.id}.videoWidth;
		var videoHeight=video{$i}{$t.id}.videoHeight; 
		//console.log('原视频-宽度：',videoWidth);
		//console.log('原视频-高度：',videoHeight);
		//视频根据窗体自动缩放
		//公式-等比例缩放后的高=（缩放后的宽度/原始宽度）*原始高度
		var Box_videoWidth=window_Width*0.5;
		var Box_videoHeight=(window_Width/videoWidth)*videoHeight*0.5; //缩放后的高度
		//console.log('视频缩放-宽度：',Box_videoWidth);
		//console.log('视频缩放-高度：',Box_videoHeight);  
		//var total_height=window_Height-(that.topTitle_height+that.footNav_height);//视频容器总高度
	
		//console.log('视频容器最大高度应为：',total_height);
		if (Box_videoWidth > Box_videoHeight) {
			$(document).ready(function(){
			$("#dplayer-{$i}-{$t.id}").attr("style", "width:100%;");
			});
		} else {
			$(document).ready(function(){
			$("#dplayer-{$i}-{$t.id}").attr("style", "width:40%;");
			});
		}
	
	}		
	{/loop}
	{/if}
</script>